<template>
    <div class="page">
        {{ text }}
    </div>
</template>
<script>
let userName = ''
export default {
    data() {
        return {
            text: '跳转中…'
        }
    },
    mounted() {
        userName = this.$route.query.loginCode;
        this.handleLogin()
    },
    methods: {
        handleLogin() {
            this.$store.dispatch('user/login', { username: userName })
                .then((res) => {
                    if (res.code == 200) {
                        window.hasOldUser = userName
                        window.hasUser = userName
                        console.log('this.$route.query.type', this.$route.query.type)
                        if (this.$route.query.type == '10') {
                            // 部门OKR
                            this.$router.push({ path: '/work/departmentList', query: {} })
                        } else if (this.$route.query.type == '20') {
                            // 科室OKR
                            this.$router.push({ path: '/work/list', query: {} })
                        } else if (this.$route.query.type == '30') {
                            // 云网调度
                            this.$router.push({ path: '/network/net/list', query: {} })
                        } else if (this.$route.query.type == '31') {
                            // 政务外网客户清单
                            this.$router.push({ path: '/network/net/customerList', query: { ...this.$route.query } })
                        } else if (this.$route.query.type == '32') {
                            // 政务外网商机清单
                            this.$router.push({ path: '/network/net/businessOpportunitiesList', query: { ...this.$route.query } })
                        } else if (this.$route.query.type == '33') {
                            // 政务外网商机预警
                            this.$router.push({ path: '/network/net/warnTable', query: { ...this.$route.query } })
                        } else if (this.$route.query.type == '34') {
                            // 政务云客户清单
                            this.$router.push({ path: '/network/cloud/customerListCloud', query: { ...this.$route.query } })
                        } else if (this.$route.query.type == '35') {
                            // 政务云商机清单
                            this.$router.push({ path: '/network/cloud/businessOpportunitiesListCloud', query: { ...this.$route.query } })
                        } else if (this.$route.query.type == '36') {
                            // 政务云商机预警
                            this.$router.push({ path: '/network/cloud/warnTableCloud', query: { ...this.$route.query } })
                        } else if (this.$route.query.type == '37') {
                            // 大庆油田商机清单
                            this.$router.push({ path: '/featuredClients/dqytList', query: { ...this.$route.query } })
                        } else if (this.$route.query.type == '40') {
                            // 地市调度清单
                            this.$router.push({ name: 'superviseListSend', params: { add: true, content: this.$route.query.content } })
                        } else {
                            // OKR待办
                            this.$router.push({ path: '/work/mytask', query: {} })
                        }
                    } else {
                        this.text = '当前用户暂无权限！'
                        this.$router.push({ path: '/login', query: {} })
                    }
                })
                .catch(() => {
                    console.log('error!!')
                    this.text = '当前用户暂无权限！'
                    this.$router.push({ path: '/login', query: {} })
                    return false
                })
        },
    }
}
</script>
<style lang="scss" scoped>
.page {
    width: 100%;
    height: 100vh;
    text-align: center;
    line-height: 100vh;
    font-size: 36px;
    font-weight: bold;
    color: #333;
}
</style>